
namespace Kaleta.Xna.Collision
{
    // .NET Fx
    using System.Collections.Generic;

    // XNA
    using Microsoft.Xna.Framework;

    

    public partial class Sap
    {
        public static int CELL_SIZE=1200;

        /// <summary>This type supports the GameDynamics infrastructure and is not intended to be used directly from your code</summary>
        private sealed class GridSort: IComparer<IBody>
        {
            #region IComparer<Body> Members
            int IComparer<IBody>.Compare(IBody a, IBody b)
            {
                int obj1_cellInd_Y = (int)a.Body.Position.Y / CELL_SIZE;
                int obj1_cellInd_X = (int)a.Body.Position.X / CELL_SIZE;

                int obj2_cellInd_Y = (int)b.Body.Position.Y / CELL_SIZE;
                int obj2_cellInd_X = (int)b.Body.Position.X / CELL_SIZE;

                if (obj1_cellInd_Y < obj2_cellInd_Y) return -1;
                if (obj1_cellInd_Y > obj2_cellInd_Y) return 1;

                if (obj1_cellInd_X < obj2_cellInd_X) return -1;
                if (obj1_cellInd_X > obj2_cellInd_X) return 1;

                if (a.Body.Position.X < b.Body.Position.X) return -1;
                if (a.Body.Position.X > b.Body.Position.X) return 1;

                return 0;
                            }
            #endregion
        }

       
    }
}
